package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.YsResultDTO;
import com.CST.service.ys.YsBudgetResultsService;
import com.CST.vo.ys.YsAllYearBudgetBusinessResultsVO;
import com.CST.vo.ys.YsAllYearBudgetManageResultsVO;
import com.CST.vo.ys.YsBudgetResultsVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author qtx
 * @since 2023-05-28
 */
@Api(tags = "预算执行结果")
@RestController
@RequestMapping("/ysDepartmentalBudgetResults")
public class YsBudgetResultsController {

    private final YsBudgetResultsService service;

    public YsBudgetResultsController(YsBudgetResultsService service) {
        this.service = service;
    }

    @ApiOperation("部门业务预算执行结果")
    @PostMapping("/listYsBusinessResults")
    public ResultObject<PageInfo<YsBudgetResultsVO>> listYsBusinessResults(@RequestBody YsResultDTO dto) {
        return ResultObject.success(service.listYsBusinessResults(dto));
    }

    @ApiOperation("部门业务预算执行结果导出")
    @PostMapping("/exportExcelYsBusinessResults")
    public void exportExcelYsBusinessResults(HttpServletResponse response, @RequestBody YsResultDTO dto) {
        service.exportExcelYsBusinessResults(response, dto);
    }

    @ApiOperation("部门管理预算执行结果")
    @PostMapping("/listYsManageResults")
    public ResultObject<PageInfo<YsBudgetResultsVO>> listYsManageResults(@RequestBody YsResultDTO dto) {
        return ResultObject.success(service.listYsManageResults(dto));
    }

    @ApiOperation("部门业务预算执行结果导出")
    @PostMapping("/exportExcelYsManageResults")
    public void exportExcelYsManageResults(HttpServletResponse response, @RequestBody YsResultDTO dto) {
        service.exportExcelYsManageResults(response, dto);
    }

    @ApiOperation("全院执行结果：业务职能")
    @PostMapping("/listYsBusinessAllResults")
    public ResultObject<YsAllYearBudgetBusinessResultsVO> listYsBusinessAllResults(@RequestBody YsResultDTO dto) {
        return ResultObject.success(service.listBusinessAllResults(dto));
    }

    @ApiOperation("全院执行结果：业务职能导出")
    @PostMapping("/exportExcelYsBusinessAllResults")
    public void exportExcelYsBusinessAllResults(HttpServletResponse response, @RequestBody YsResultDTO dto) throws IOException {
        service.exportExcelYsBusinessAllResults(response, dto);
    }

    @ApiOperation("全院执行结果：管理职能")
    @PostMapping("/listYsManageAllResults")
    public ResultObject<PageInfo<YsAllYearBudgetManageResultsVO>> listYsManageAllResults(@RequestBody YsResultDTO dto) {
        return ResultObject.success(service.listYsManageAllResults(dto));
    }

    @ApiOperation("全院执行结果：管理职能导出")
    @PostMapping("/exportExcelYsManageAllResults")
    public void exportExcelYsManageAllResults(HttpServletResponse response, @RequestBody YsResultDTO dto) {
        service.exportExcelYsManageAllResults(response, dto);
    }
}
